/*
 * @Author: wuyue
 * @Date: 2023-03-03 11:27:12
 * @LastEditTime: 2023-03-03 12:17:31
 * @LastEditors: wuyue
 * @Descripttion: 导出
 * @version: 
 */
//
export default function handleDownload(api, params, name){
    api(params).then(res=> {
        if (res.data) {
            const blob = new Blob([res.data])
            // const filename = decodeURIComponent(res.headers['content-disposition'].split('filename=')[1])
            const downloadElement = document.createElement('a')
            downloadElement.setAttribute('download', name + '.xls')
            const href = window.URL.createObjectURL(blob) // 创建下载的链接
            downloadElement.href = href
            document.body.appendChild(downloadElement)
            downloadElement.click() //点击下载
            document.body.removeChild(downloadElement) //下载完成移除元素
            window.URL.revokeObjectURL(href) //释放blob对象
        }
    })
  }